﻿@model TextRPG.Models.Item

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Item</legend>

        @Html.HiddenFor(model => model.ItemID)

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.BaseValue)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.BaseValue)
            @Html.ValidationMessageFor(model => model.BaseValue)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ItemDefinitionID, "Item Definition")
        </div>
        <div class="editor-field">
            @Html.DropDownList("ItemDefinitionID", String.Empty)
            @Html.ValidationMessageFor(model => model.ItemDefinitionID)
        </div>

    <table> 
    <tr> 
        <th>ID</th> 
        <th>Name</th> 
        <th>postfix</th> 
        <th>value</th> 
    </tr> 
     @foreach (var item in Model.AttachedModifiers)
     {
         <tr>
            <td>
                @item.AttachedModifierID
            </td>
            <td>
                @item.Name
            </td>
            <td>
                @item.postfix
            </td>
            <td>
                @item.value
            </td>
            <td>
               @Html.ActionLink("Remove Modifier", "RemoveModifier", new { id = item.ModifierID, redirection = "Edit", redirectionValue = Model.ItemID})
            </td>
         </tr>
     }
</table> 
     @Html.ActionLink("Add Modifier", "AddModifier", new { id = Model.ItemID, redirection = "Edit", redirectionValue = Model.ItemID})

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
